<?php

namespace App\Admin\Controllers;

use Dcat\Admin\Http\Controllers\AuthController as BaseAuthController;
use Guanguans\DcatLoginCaptcha\Facades\CaptchaBuilder;
use Guanguans\DcatLoginCaptcha\Facades\PhraseBuilder;
use Illuminate\Support\Facades\Session;

class AuthController extends BaseAuthController
{
    protected $view = 'login';
    public function captcha() {
        $phrase = new PhraseBuilder();
        $code = $phrase->build(4);
        $builder = new CaptchaBuilder($code, $phrase);
        $builder->setBackgroundColor(220, 210, 230);

        $builder->setMaxAngle(25);
        $builder->setMaxBehindLines(0);
        $builder->setMaxFrontLines(0);
        $builder->build(300, 80);
        $phrase = $builder->getPhrase();
        Session::put('code', $phrase);
        Session::save();
        $builder->output();
    }
}
